package com.ybzl.common.event;

import org.springframework.context.ApplicationEventPublisher;
import org.springframework.context.ApplicationEventPublisherAware;
import org.springframework.stereotype.Component;

/**
 * 事件发布者
 */
@Component
public class DefaultPublisher implements ApplicationEventPublisherAware {

    private ApplicationEventPublisher publisher;

    public void operInit(String topic, String message) {
        DefaultEvent event = new DefaultEvent("","");
        event.setTopic(topic);
        event.setMessage(message);
        publisher.publishEvent(event);
    }

    @Override
    public void setApplicationEventPublisher(ApplicationEventPublisher applicationEventPublisher) {
        this.publisher = applicationEventPublisher;
    }

}
